package com.istart.aop.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/**
 * 打印日志的切面(包含Advice和Pointcut)
 */
public class LogInvocationHandler implements InvocationHandler {

	private Object target;
	
	public LogInvocationHandler(Object target) {
		super();
		this.target = target;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		//执行原有逻辑
		Object rev = method.invoke(target, args);
		////执行织入的日志
		if (method.getName().equals("doSomeThing")) {
			System.out.println("动态代理记录日志");
		}
		return rev;
	}

}
